home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / apply < prev    next >
Text File  |  2001-04-06  |  1KB  |  36 lines

  1. SYNOPSIS
  2.         mixed apply(closure cl, ...)
  3.  
  4. DESCRIPTION
  5.         Evaluates the closure <cl>.
  6.         If <cl> is not a closure, it will simply be returned (and all
  7.         other arguments are ignored).
  8.  
  9.         One might wonder why there are two functions, funcall() and
  10.         apply(), to perform the seemingly same job, namely evaluating
  11.         a closure. Of course there is a subtle difference. If the last
  12.         argument to apply() is an array, then each of its elements
  13.         gets expanded to an additional paramater. The obvious use
  14.         would be #'call_other as in:
  15.  
  16.         mixed eval(object ob,string func,mixed *args)
  17.         {
  18.           return apply(#'call_other,ob,func,args);
  19.         }
  20.  
  21.         This will result in calling
  22.         ob->func(args[0],args[1],...,args[sizeof(args)-1]).
  23.         Using funcall() instead of apply() would have given us
  24.         ob->func(args).
  25.  
  26.         One important application of apply() is the 'flattening' of
  27.         the argument array received in varargs functions.
  28.  
  29. HISTORY
  30.         Introduced in 3.2@70
  31.         LDMud 3.2.8 adds the returning of a non-closure as first
  32.         argument.
  33.  
  34. SEE ALSO
  35.         funcall(E), closures(LPC), varargs(LPC)
  36.